package com.kestrel.space.core.controller;

import com.kestrel.space.common.controller.BaseController;
import com.kestrel.space.common.utils.LargePage;
import com.kestrel.space.common.utils.Result;
import com.kestrel.space.core.model.Organization;
import com.kestrel.space.core.query.OrganizationQuery;
import com.kestrel.space.core.service.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yebolin
 * @date 2024/8/23
 */
@RestController
@RequestMapping("organization")
public class OrganizationController extends BaseController {
    @Autowired
    private OrganizationService organizationService;

    /**
     * 增删改查全表（内部）
     * @param query
     * @return
     */
    @RequestMapping("listContent")
    public Result listContent(@RequestBody OrganizationQuery query){
        return Result.list(organizationService.listContent(query, new LargePage(query.getPage(), query.getRows())));
    }
    @RequestMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody Organization organization){
        return Result.ok(organizationService.saveOrUpdate(organization));
    }
    @RequestMapping("batchSaveOrUpdate")
    public Result batchSaveOrUpdate(@RequestBody List<Organization> organizationList){
        return Result.ok(organizationService.batchSaveOrUpdate(organizationList));
    }
}
